<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>dept_mag.jsp</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">

		<link rel="stylesheet" type="text/css" href="./css/style.css">
		
		<script type="text/javascript">
		function edit(){
			var c=document.getElementsByName("detail");
			var i=0;
			var id;
			for(i=0;i<c.length;i++){
			if(c[i].checked==true){
			id=c[i].value;
			break;
			  }
			}
			if(id==null||id==""){
			 alert("请选择其中一个");
			 }else{
			url="./dept/deptEditAction?id="+id;
			location.href=url;
		}
		}
		function check(){
		    var id;			
			var c = document.getElementsByName("delgroup");
			var i=0;
			for(i=0;i<c.length;i++){
				if(c[i].checked==true){
					id = c[i].value;
					break;
				}
			}
		if(id==null||id==""){
				alert("请选择后再进行删除操作！");
				return false;
		}else{
		     question=confirm("您确定要删除吗");
		     if(question==true){
		     return true;
		     alert("删除成功");
		     }else {
		     return false;
		     }
		}
		}
		
		</script>
	</head>
	
	<body>

		<div id="blue_button">
			<div id="blue_button_word">
				&nbsp;部门管理
			</div>
		</div>

		<div id="right_background">
			&nbsp;
			<br />
			<br />
			<br />
			<form action="./dept/delDeptAction.action" method="post" id="formm" onsubmit="return check()">
			 
				<table cellspacing="1" class="tab_dept">

					<tr class="tab_header">
						<td valign="middle" align="center">
							部门名称
						</td>
						<td valign="middle" align="center">
							联系电话
						</td>
						<td valign="middle" align="center">
							负责人
						</td>
						<td valign="middle" align="center">
							修改
						</td>
						<td valign="middle" align="center">
							删除
						</td>
					</tr>

					<s:iterator value="deptlist" var="list">
						<tr class="row2" onMouseOver="this.className='row1'"
							onMouseOut="this.className='row2'">
							<td valign="middle" align="center">
								<s:property value="#list.dname" />
								
							</td>
							
							<td valign="middle" align="center">
								<s:property value="#list.DPhone" />
							</td>
							<td valign="middle" align="center">
								<s:property value="#list.comEmp.EName" />
			                </td>
							<td valign="middle" align="center">
								<input type="radio" id="detail" name="detail" value="<s:property value="#list.deptno" />"  />
							</td>
							<td valign="middle" align="center">
							<input type="checkbox"  id="delgroup" name="delgroup" value="<s:property value="#list.deptno" />"  />
							</td>
						</tr>
					</s:iterator>
				</table>
				&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
               <font color="orange" style="magin-right:10%">${msg2}</font><br/>
				<input type="button" class="del" value="新 增"
					style="margin-top: 20px; margin-left: 610px;"
					onclick="location.href='./dept/showAddDeptAction'" />
				&nbsp; 
				<input type="button" class="add" value="修  改"  onClick="edit();"/>
				&nbsp; 
				<input type="submit" class="add" value="删  除" onClick="del();"/>
			</form>
			
			<br/>
			<p class="paging" style="text-align: center">
			<s:if test="%{currentPage == 1}">
				&lt;&lt; 首页 &lt; 上一页
			</s:if>
			<s:else>
				<a href="./dept/dept2Action?page=1"> &lt;&lt;首页</a>
				<a href="./dept/dept2Action?page=${currentPage-1}">&lt; 上一页 </a>
			</s:else>
		
			<strong>第${currentPage}页/共${totalPages}页</strong>
			
			<s:if test="%{currentPage == totalPages}">
				下一页 &gt;
				末页 &gt;&gt;
			</s:if>
			<s:else>
				<a href="./dept/dept2Action?page=${currentPage+1}"> 下一页 &gt;</a>
				<a href="./dept/dept2Action?page=${totalPages}">末页 &gt;&gt;</a>
			</s:else>
		</p>
</div>
	</body>
</html>
